<template>
  <a-modal :mask-closable="false"  v-model:visible="visible" fullscreen :footer="false">
    <template #title>任务文件</template>
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </a-modal>
</template>
<script setup>
import { ref, reactive } from 'vue'
import lzccTaskfile from '@/api/lzcc/lzccTaskfile'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()
const visible = ref(false)
const currentRow = ref({ id: undefined })

const open = (row) => {
  currentRow.value = row
  crudRef.value.requestData()
  visible.value = true
}

const options = reactive({
  autoRequest: false,
  beforeRequest: (params) => {
    params.task_id = currentRow.value.id
  },
  id: 'flyos_lzcc_taskfile',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: lzccTaskfile.getList,
})

const columns = reactive([
  {
    title: "文件路径",
    dataIndex: "file_url",
    formType: "upload",
    type: "file",
    multiple: false
  },
    {
    title: "部分名称",
    dataIndex: "part_name",
  },
  {
    title: "所属任务日期",
    dataIndex: "task_date",
  },
  {
    title: "审核时间",
    dataIndex: "audit_time",
  },
  {
    title: "审核状态",
    dataIndex: "status",
    formType: "select",
    search: true,
    dict: {
      name: "audit_status",
      props: {
        label: "title",
        value: "key"
      },
      translation: true,
      tagColors: { '2': 'blue', '3': 'red', '4':'green', '5':'magenta'}
    }
  },
])

defineExpose({ open })
</script>